package cn.migu.music.hangupsms.schedule;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.migu.music.common.utils.LogUtils;
import cn.migu.music.hangupsms.common.config.HangUpSmsConfig;
import cn.migu.music.hangupsms.dbcache.BlackUserCacheManager;
import cn.migu.music.schedule.ScheduleJobExecutor;
import cn.migu.music.schedule.api.mq.JobExecuteNotify;
import lombok.extern.slf4j.Slf4j;

@Service("hangupSmsBlackUserRedisRefreshJob")
@Slf4j
public class BlackUserRedisRefreshJob implements ScheduleJobExecutor {
    @Autowired
    private BlackUserCacheManager blackUserCacheManager;
    @Autowired
    private HangUpSmsConfig       hangUpSmsConfig;

    @Override
    public void execute(JobExecuteNotify jobExecuteNotify) {
        LogUtils.info(log, "hangupSmsBlackUserRefreshJob start!");
        if (!hangUpSmsConfig.isBlackUserCacheSwitchOn()) {
            return;
        }
        blackUserCacheManager.loadAllBlackList(false);
    }
}
